Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Assignment Expression (Walrus) In Conditional #518

Closed

Conversation

pixeebot[bot]
Copy link
Contributor

@pixeebot pixeebot bot commented Feb 20, 2024

This codemod updates places where two separate statements involving an assignment and conditional can be replaced with a single Assignment Expression (commonly known as the walrus operator).

Many developers use this operator in new code that they write but don't have the time to find and update every place in existing code. So we do it for you! We believe this leads to more concise and readable code.

The changes from this codemod look like this:

- x = foo()
- if x is not None:
+ if (x := foo()) is not None:
      print(x)
More reading

Powered by: pixeebot (codemod ID: pixee:python/use-walrus-if)

@dwanderson-intel
Copy link
Contributor

not embracing walrus just yet

@dwanderson-intel dwanderson-intel deleted the pixeebot/drip-2024-02-20-pixee-python/use-walrus-if branch February 21, 2024 21:26
@tjs-intel tjs-intel restored the pixeebot/drip-2024-02-20-pixee-python/use-walrus-if branch February 26, 2024 16:30
@tjs-intel tjs-intel mentioned this pull request Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant